﻿<UserControl 
    x:Class="SilverlightInEnterprise.Caching.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:vm="clr-namespace:SilverlightInEnterprise.Caching.ViewModels" 
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
    xmlns:cache="clr-namespace:SilverlightInEnterprise.Caching.ServiceContractSL.DTOCache;assembly=SilverlightInEnterprise.Caching.ServiceContractSL">
	<UserControl.Resources>
		<DataTemplate x:Key="ProductColumDataTemplate">
			<Grid>
				<ComboBox d:LayoutOverrides="Height" ItemsSource="{Binding Path=Products.Items, Source={StaticResource Cache}}" DisplayMemberPath="DisplayName" SelectedValuePath="Id" SelectedValue="{Binding Path=ActiveProductId,Mode=TwoWay}"  />
			</Grid>
		</DataTemplate>
	</UserControl.Resources>

    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.RowDefinitions>
            <RowDefinition Height="60*" />
            <RowDefinition Height="240*" />
        </Grid.RowDefinitions>
        <Grid.DataContext>
            <vm:MainViewModel />
        </Grid.DataContext>
        <Button Content="Load Items" Command="{Binding Path=GetSalesItemsCommand}" VerticalAlignment="Center" HorizontalAlignment="Left"  />
        <sdk:DataGrid AutoGenerateColumns="False"  Name="dataGrid1" Grid.Row="1" ItemsSource="{Binding Path=Items}">
            <sdk:DataGrid.Columns>
                <sdk:DataGridTextColumn Header="Item Id" IsReadOnly="True" Binding="{Binding Id}" />
                <sdk:DataGridTemplateColumn Header="Product" CellEditingTemplate="{StaticResource ProductColumDataTemplate}" />
                <sdk:DataGridTextColumn Header="Units" Binding="{Binding Path=Units}" />
                <sdk:DataGridTextColumn Header="Price" IsReadOnly="True" Binding="{Binding Path=Price}" />
                <sdk:DataGridTextColumn Header="Total" IsReadOnly="True" Binding="{Binding Path=Total}" />
            </sdk:DataGrid.Columns>
        </sdk:DataGrid>
    </Grid>
</UserControl>
